/**
 * Created by icyhy on 2017/5/22.
 */
var mysql = require("../connect.js");

var userModel = {
  login: function () {
    mysql.query('SELECT 1 + 1 AS solution', function(err, rows, fields) {
      if (err) throw err;
      return  rows[0].solution;
    });
  }
}

//关闭连接
/*var userSchema = new mongoose.Schema({
  subscribe: Number,
  openid: String,
  nickname: String,
  sex: Number,
  city: String,
  province: String,
  country: String,
  headimgurl:  String,
  subscribe_time: Number,
  unionid: String,
  remark: String,
  groupid: Number,
  clanid:String, //用户参加的部落，当前只允许用户参加一个部落
  created: {
    type: Date,
    default: Date.now
  },
  used: {//是否启用
    type: Boolean,
    default: true
  }
});

userSchema.statics.findByOpenid = function (openid, cb) {
  this.findOne({openid:openid}, function (err, result) {
    if (err) throw err;
    return cb(null, result);
  });
};

userSchema.statics.findByUserid = function (userid, cb) {
  this.findOne({_id:userid}, function (err, result) {
    if (err) throw err;
    return cb(null, result);
  });
};


var userModel = db.model("user", userSchema);*/
module.exports = userModel;
